<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<div id="app">
    <input type="button" value="添加" @click="add">
    <input type="button" value="移除" @click="remove">
    <ul>
        <li v-for="(item,index) in vegetables">
           {{index+1}} 我喜欢吃：{{item}}
        </li>
    </ul>
    <h2 v-for="item in arr" v-bind:title="item.name">
        {{item.name}}
    </h2>

</div>

    
    <script src="vue.js"></script>
    <script>
        var app=new Vue({
            el:"#app",
            data:{
                vegetables:[
                    "青菜",
                    "土豆",
                    "番茄",
                    "西红柿"
                ],
                arr:[
                    {name:"cjl"},
                    {name:"lxq"},
                    {name:"lzq"}
                ]
            },
            methods:{
               add:function() {
                   this.vegetables.push("冬瓜");
               },
               remove:function(){
                this.vegetables.shift();
               }
            }
        })

    </script>
</body>
</html>
